<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 箭头函数
      let fu1 = (name) => {
        // 函数体
        return `Hello ${name} !`;
      };

      // 等同于
      let fn2 = function (name) {
        // 函数体
        return `Hello ${name} !`;
      };

      //   普通函数
      var a = "jhssah";

      function fn3() {
        setTimeout(function () {
          console.log(this.a);
        }, 2000);
      }

      function fn4() {
        // setTimeout中使用箭头函数
        setTimeout(() => {
          console.log(this.a);
        }, 2000);
      }

      fn3.call({ a: "Obj" }); // 'Global'
      fn4.call({ a: "Obj" }); // 'Obj'
    </script>
  </body>
</html>
